#include <iostream>
using namespace std;
struct node
{
    int data;
    node *next;
};
typedef node *Stack;
Stack initStack()
{
    Stack s = new node;
    s->next = NULL;
    return s;
};
void push(Stack &s, int data)
{
    node *tmp = new node;
    tmp->data = data;
    tmp->next = s->next;
    s->next = tmp;
}
int top(Stack &s) { return s->next->data; };
bool pop(Stack &s, int &data)
{
    if (s->next == NULL)
        return false; //空栈
    node *tmp = new node;
    tmp = s->next;
    data = tmp->data;
    s->next = s->next->next;
    delete tmp;
    return true;
}
int main()
{
    int arr[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, data;
    Stack s = initStack();
    for (int i = 0; i < 10; ++i)
    {
        push(s, arr[i]);
    }
    for (int i = 0; i < 100; ++i)
    {
        if (pop(s, data))
            cout << data << " ";
    }
    return 0;
}